package com.example.dangdangbackend.controller;

import com.example.dangdangbackend.service.ItemService;
import com.example.dangdangbackend.service.PayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/trade")
public class PayController {
    @Autowired
    private PayService payService;
    @Autowired
    private ItemService itemService;

    @RequestMapping("/pay")
    public void pay(int orderId)throws Exception {
        payService.pay(orderId);
        itemService.setItemOrder(orderId);
    }
    @PostMapping("/notify")
    public void notifyUrl()throws Exception {
        System.out.println("this is notify ");
        payService.payNotify();
    }
    @RequestMapping("/return")
    public void returnUrl()throws Exception {
        System.out.println("return");
        payService.payReturn();

    }
}
